﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../lib/html5.js"></script>
<script type="text/javascript" src="../lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>采收管理</title>
    <style type="text/css">
        .auto-style1 {
            width: 40px;
        }

        td.details-control {
            background: url('../lib/Hui-iconfont/details_open.png') no-repeat center center;
            cursor: pointer;
        }

        tr.shown td.details-control {
            background: url('../lib/Hui-iconfont/details_close.png') no-repeat center center;
        }
    </style>
</head>
<body>
    <div class="pd-5">
        <div class="text-c" id="findfdiv">
            <!-- 生日范围：
            <input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'finddt1_timee\')||\'%y-%M-%d\'}'})" id="finddt1_times" name="finddt1_times" class="input-text Wdate" style="width: 120px;">
            -
            <input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'finddt1_times\')}',maxDate:'%y-%M-%d'})" id="finddt1_timee" name="finddt1_timee" class="input-text Wdate" style="width: 120px;">-->

            <span class="select-box" style="width: 200px;">
                <select class="select" size="1" name="findfv5" id="findfv5">
                </select>
            </span>
            <!--     <span class="select-box" style="width: 200px;">
                <select class="select" name="findtype" id="findtype">
                    <option value="">所有作业</option>
                    <option value="生产任务">生产任务</option>
                    <option value="育苗任务">育苗任务</option>
                </select>
            </span>
            <span class="select-box" style="width: 200px;">
                <select class="select" name="findtaskstatus" id="findtaskstatus">
                    <option value="">所有状态</option>
                    <option value="计划">计划</option>
                    <option value="种植">种植</option>
                    <option value="完成">完成</option>
                    <option value="中止">中止</option>
                </select>
            </span>
            <input type="text" class="input-text" style="width: 150px" placeholder="编号" id="findtaskno" name="findtaskno">-->
            <input type="text" class="input-text" style="width: 150px" placeholder="地块" id="findfv1" name="findfv1">

            <button onclick="findreolad2()" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 查询</button>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-5">
            <span class="l">
                <!-- <a href="javascript:;" onclick="toolDelete()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 删除</a>-->
                <!--<a href="javascript:;" onclick="toolUpdate()" class="btn btn-secondary radius"><i class="Hui-iconfont">&#xe6df;</i> 修改</a>-->
                <!--    <a href="javascript:;" onclick="toolAdd()" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加生产任务</a>
                <a href="javascript:;" onclick="toolAddYM()" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加育苗任务</a>-->

            </span>
            <span class="r">
                <!-- <a href="javascript:;" onclick="toolAdd()" class="btn btn-success radius"><i class="Hui-iconfont">&#xe603;</i> 查看明细表</a>-->

            </span>

        </div>
        <div class="mt-5 ml-20">
            <table class="table table-border table-bordered table-striped table-hover" id="tablelist" width="100%">
                <thead>
                    <tr class="text-c">
                        <th width="30"><a id="hcmtable_sall" onclick="hcmtable_sall();" href="javascript:;" title="全选反选"><i class="Hui-iconfont">&#xe608;全</i></a></th>
                        <th>编号</th>
                        <th>区域</th>
                        <th>总面积</th>
                        <th>类型</th>
                        <th>片区主管</th>
                        <th>生产工人</th>
                        <th>说明</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>

        </div>
    </div>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="../lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../lib/datatables/1.10.0/jtable.js"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../js/hcui_list.js"></script>
    <script type="text/javascript">
        function toolAddYM() {
            toolAdd("新增育苗任务", "sctasklist-ymae.html?action=add");
        }        function toolUpdateBychange(id, type) {
            if (type == "育苗任务") toolUpdateById(id, '编辑育苗任务信息', 'sctasklist-ymae.html?action=edit&id=' + id);
            else toolUpdateById(id, '编辑生产任务信息', 'sctasklist-ae.html?action=edit&id=' + id);
        }
        tablelistSelectType = 0;//1行多选(默认) 0行单选  
        var selectworktypeinfo = [];//所有作业类型
        $(function () {
            hcdoselbyPost("id,fv1 as name,fv3,fv4", "yw_baseinfo", "type='4' and  maintype='4' and fv3='11'", "", "", "id",
           function (data) {
               selectworktypeinfo = data;
           });
            spsetBaseNoBt("yw_baseinfo", "id", "yw_baseinfo as T", "*", "#tablelist", "baseinfo2", "生产任务管理", "baseinfo2");
            //加载区域
            hcdoselbyPost("id,fv1 as name", "yw_baseinfo", "type='5' and  maintype='5' and databranchid=" + HCUser.HCUorg, "", "", "id",
                   function (data) {
                       SetSelectWithArrayIdName("#findfv5", data);
                   });

            hcmtable = $("#tablelist").DataTable({
                "serverSide": true,//服务端处理分页 无法使用当前查找
                "bFilter": false,  //是否使用内置的过滤功能
                "bInfo": true, "fnDrawCallback": function () { dTappendSkipPage(); },
                //"ajax": spselUrl(" and type=20150921"),
                "ajax": {
                    "type": "POST",
                    "url": spselUrl("and type=2 and maintype=2 and databranchid=" + HCUser.HCUorg, "id,type,taskno,tasksctypename,taskid,infotype,infobytype1,infoid,infotypename,infofv1,infofv2,infonv1#view进行中的任务#infoid-@id#infotype asc") + "&sporderby= dataaddtime desc ",
                    "data": function (d) {
                        if (hcmtable != null && hcmtable != 'undefined') {
                            var info = hcmtable.page.info();
                            var dataRows = info.recordsTotal;//回传总行数
                            d["hcrainallrow"] = dataRows;
                        }
                        else {
                            d["hcrainallrow"] = 0;
                        }
                        $("#findfdiv").find("input[type='text']").each(function () {
                            d[this.id] = $(this).val();
                        });
                        $("#findfdiv").find("select").each(function () {
                            d[this.id] = $(this).val();
                        });

                    }
                },
                "order": [[1, "desc"]],//默认第几个排序
                aLengthMenu: [10, 20,30, 50,100],
                //"columns": [{ "data": "rowhcindex" }, { "data": "taskno" }, { "data": "taskinfo" }, { "data": "taskinfo" }, { "data": "tasksctype" }, { "data": "newwork" }, { "data": "dataaddtime" }, { "data": "id" }
                //],
                "columns": [
                  {
                      "class": 'details-control',
                      "orderable": false,
                      "data": null,
                      "defaultContent": ''
                  },
                  { "data": "fv1" }, { "data": "fv4" }, { "data": "nv1" }, { "data": "fv8" }, { "data": "fv9" }, { "data": "fv6" }, { "data": "fv3" }, { "data": "id" }
                ],


                "columnDefs": [

                    //特殊显示列
                    //{
                    //    "targets": [6],
                    //    "render": function (data, type, row) {
                    //        if (data == "") return "";
                    //        else if (data == "保密") return "<span class=\"label radius\">" + data + "</span>";
                    //        else return "<span class=\"label label-success radius\">" + data + "</span>";
                    //    }
                    //}
                    //,
                   // 操作列
                    //{
                    //    "targets": [7],
                    //    "render": function (data, type, row) {
                    //        if (row.taskstatus == '完成' || row.taskstatus == '中止') {
                    //            return "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolUpdateById('" + data + "')\" href=\"javascript:;\" title=\"查看\"><i class=\"Hui-iconfont\">&#xe685;查看</i></a> ";
                    //        }
                    //        else {
                    //            return "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolUpdateBychange('" + data + "','" + row.type + "')\" href=\"javascript:;\" title=\"编辑\"><i class=\"Hui-iconfont\">&#xe6df;编辑</i></a> " +
                    //                   "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolDelete('" + data + "')\"     href=\"javascript:;\" title=\"删除\"><i class=\"Hui-iconfont\">&#xe6e2;删除</i></a>";
                    //        }
                    //    }
                    //},

                    //不排序
                   {
                       "orderable": false,
                       "targets": [0, 2, 3, 4, 5]
                   }
                  // ,
                  // //不显示
                  //{
                  //    "targets": [ 8],
                  //    "visible": false
                  //}

                ]
            });

            $('#tablelist tbody').on('click', 'td.details-control', function () {
                var tr = $(this).closest('tr');
                var row = hcmtable.row(tr);
                if (row.child.isShown()) {
                    // This row is already open - close it
                    row.child.hide();
                    tr.removeClass('shown');
                }
                else {
                    // Open this row
                    row.child(format(row.data())).show();
                    tr.addClass('shown');
                }
            });
        });

        function format(d) {
            console.log(d);
            //var reinfo= '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">' +
            //    '<tr>' +
            //        '<td>最新作业:</td>' +
            //        '<td>' + d.newwork + '</td>' +
            //    '</tr>' +
            //    '<tr>' +
            //        '<td>最新作业时间:</td>' +
            //        '<td>' + d.newworktime + '</td>' +
            //    '</tr>' +
            //    '<tr>' +
            //        '<td>最新作业人:</td>' +
            //        '<td>' + d.newworkusername + '</td>' +
            //    '</tr>' +
            //'</table>';
            var allmj = d.nv1 * 1;
            var trStr = "";
            var objList = d.subinfo;
            for (var i = 0; i < objList.length; i++) {
                allmj = allmj - objList[i].infonv1 * 1;
                //循环遍历出json对象中的每一个数据并显示在对应的td中 
                trStr += '<tr>';//拼接处规范的表格形式 
                trStr += '<td >' + objList[i].taskno + '/' + objList[i].type + '</td>';
                trStr += '<td >' + objList[i].tasksctypename + '</td>';
                trStr += '<td>' + objList[i].infonv1 + '</td>';
                //selectworktypeinfo
                if (objList[i].infotype == 1 && objList[i].infobytype1 == 1) {//地块信息
                    if (d.taskstatus != '完成' && d.taskstatus != '中止') {
                        trStr += '<td>';
                        for (var wi = 0; wi < selectworktypeinfo.length; wi++) {
                            trStr += "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"addTaskListInfo('" + selectworktypeinfo[wi].id + "','" + objList[i].infonv1 + "','" + d.id + "','" + objList[i].id + "','" + selectworktypeinfo[wi].fv3 + "','" + selectworktypeinfo[wi].name + "')\" href=\"javascript:;\" title=\"" + selectworktypeinfo[wi].name + "\"><i class=\"Hui-iconfont\">" + getimgcode(selectworktypeinfo[wi].fv3) + selectworktypeinfo[wi].name + "</i></a> ";
                            //selectworktypeinfo[wi].fv3 + selectworktypeinfo[wi].name + "/";
                        }

                        trStr += '</td>';
                    }
                    else { trStr += '<td/>'; }
                }
                else {
                    if (d.taskstatus == '完成' || d.taskstatus == '中止') {
                        trStr += '<td>' +
      "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolUpdateByIdCheckUrl('" + objList[i].id + "','sctasklist-work-ae.html','处理作业信息')\" href=\"javascript:;\" title=\"查看\"><i class=\"Hui-iconfont\">&#xe685;查看</i></a> ";
                        '</td>';
                    }
                    else {
                        trStr += '<td>' +
      "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolUpdateByIdCheckUrl('" + objList[i].id + "','sctasklist-work-ae.html','处理作业信息')\" href=\"javascript:;\" title=\"编辑\"><i class=\"Hui-iconfont\">&#xe6df;编辑</i></a> " +
      "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolDelete('" + objList[i].id + "','hsc_task_info','id')\"     href=\"javascript:;\" title=\"删除\"><i class=\"Hui-iconfont\">&#xe6e2;删除</i></a>"
                        '</td>';
                    }


                }
                trStr += '</tr>';

            }
            //空地
            //trStr += '<tr>';
            //trStr += '<td >空地</td>';
            //trStr += '<td >空地</td>';
            //trStr += '<td>' + allmj.toFixed(2) + '</td>';
            //trStr += '<td>' +
            //            "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"addTaskForBJ('" + d.id + "','" + allmj + "')\" href=\"javascript:;\" title=\"播种\"><i class=\"Hui-iconfont\">&#xe6d3;播种任务</i></a> " +
            //            "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"addTaskForYM('" + d.id + "','" + allmj + "')\" href=\"javascript:;\" title=\"育苗\"><i class=\"Hui-iconfont\">&#xe6bb;育苗任务</i></a> "
            //    + '</td>';
            //trStr += '</tr>';
            var reinfo2 =
                '<table class="table table-border" >' +
                                '<thead>' +
                                    '<tr class="text-c">' +
                                        '<th>任务</th>' +
                                        '<th>品种</th>' +
                                        '<th>面积</th>' +
                                       '<th>生产农事</th>' +
                                    '</tr>' +
                               '</thead>' +
                                '<tbody id="tbody1">' + trStr +
                                '</tbody>' +
                            '</table>';
            return "" + reinfo2;

        }
        function getimgcode(workid) {
            if (workid == "2") { return "&#xe603;"; }
            else if (workid == "3") { return "&#xe64d;"; }
            else if (workid == "4") { return "&#xe6d1;"; }
            else if (workid == "5") { return "&#xe6c9;"; }
            else if (workid == "6") { return "&#xe6d3;"; }
            else if (workid == "7") { return "&#xe6b2;"; }
            else if (workid == "8") { return "&#xe6ac;"; }
            else if (workid == "9") { return "&#xe6bb;"; }
            else if (workid == "10") { return "&#xe606;"; }
            else if (workid == "11") { return "&#xe672;"; }
            else if (workid == "12") { return "&#xe688;"; }
            else if (workid == "13") { return "&#xe64d;"; }
            else if (workid == "14") { return "&#xe64d;"; }
            else if (workid == "15") { return "&#xe64d;"; }
            return "&#xe64d;";

        }

        function addTaskListInfo(worktype, workmj, dcid, taskid,worknum,workname) {
            if (worknum == 2 || worknum == 3 || worknum == 5 || worknum == 10)
            {
                opensimplediv("生产农事登记---" + workname, "sctasklist-worknewsimple-ae.html?action=add&urltaskid=" + taskid + "&urldcid=" + dcid +
                      "&urlworktype=" + worktype + "&urlworkmj=" + workmj + "&urlworknum=" + worknum);
            }
            else if (worknum == 4 || worknum == 7) {//底肥 水肥
                toolAdd("生产农事登记---" + workname, "sctasklist-worknewdf-ae.html?action=add&urltaskid=" + taskid + "&urldcid=" + dcid +
                      "&urlworktype=" + worktype + "&urlworkmj=" + workmj + "&urlworknum=" + worknum);
            }
            else if (worknum == 8) {//值保
                toolAdd("生产农事登记---" + workname, "sctasklist-worknewzb-ae.html?action=add&urltaskid=" + taskid + "&urldcid=" + dcid +
                      "&urlworktype=" + worktype + "&urlworkmj=" + workmj + "&urlworknum=" + worknum);
            }
            else if (worknum == 11)//采收
            {
                toolAdd("生产农事登记---" + workname, "sctasklist-worknewget-ae.html?action=add&urltaskid=" + taskid + "&urldcid=" + dcid +
                       "&urlworktype=" + worktype + "&urlworkmj=" + workmj + "&urlworknum=" + worknum);
            }
            else
            {
                toolAdd("生产农事登记", "sctasklist-worknew-ae.html?action=add&urltaskid=" + taskid + "&urldcid=" + dcid +
                      "&urlworktype=" + worktype + "&urlworkmj=" + workmj);
            }
            

            //if (taskid != "" && taskid != null && taskid != 'undefined') {



            //}
            //else {
            //    layer.alert("请在编辑情况下操作", { icon: 1 });
            //}
        }

        function addTaskForBJ(dkid, mj) {
            toolAdd("新增播种任务", "sctasklist_simple-ae.html?action=add&urlinfoid=" + dkid + "&urlinfomj=" + (mj * 1).toFixed(2));
        }        function addTaskForYM(dkid, mj) {
            toolAdd("新增育苗任务", "sctasklist_simple-ymae.html?action=add&urlinfoid=" + dkid + "&urlinfomj=" + (mj * 1).toFixed(2));
        }
        //重新加载--不自动刷新列表
        function findreolad(isback) {
        }
        function findreolad2(isback) {
            if (hcmtable) {
                if (isback && isback == "sdivclosed")
                    hcmtable.ajax.reload(null, false);
                else
                    hcmtable.ajax.reload();

            }
        }

    </script>
</body>
</html>
